package patrol.mobile.com.mobilepatrol.activity.security.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.emergency.EmergencyCheck4Activity;
import patrol.mobile.com.mobilepatrol.bean.CheckEntityBean;

/**
 * Created by K on 2018/9/11.
 * des:
 */
public class EmergencyCheckInfoListAdapter extends BaseQuickAdapter<CheckEntityBean.CheckDetailListBean> {
    public EmergencyCheckInfoListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_evaluation_detail;
    }

    @Override
    protected void convert(BaseViewHolder holder, final CheckEntityBean.CheckDetailListBean item) {
        holder.setText(R.id.tv_num, (holder.getLayoutPosition() + 1) + "");
        holder.setText(R.id.tvTitle, item.getCheckItem());
        holder.setText(R.id.tv_totalStore, item.getTotalStore() + "");


        holder.getView(R.id.re_spand).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, EmergencyCheck4Activity.class);
                intent.putExtra("id", item.getId());
                mContext.startActivity(intent);
            }
        });
        holder.setText(R.id.tv_remove, "扣" + item.getCheckScore() + "");
        holder.setText(R.id.tv_left, "总" + item.getTotalStore() + "分");
        holder.setText(R.id.tv_text, item.getCheckContent());
        ImageView iv_arrow = holder.getView(R.id.iv_arrow);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (holder.getView(R.id.re_spand).getVisibility() == View.VISIBLE) {
                    holder.getView(R.id.re_spand).setVisibility(View.GONE);
                    iv_arrow.setImageResource(R.mipmap.arrow_d);
                } else {
                    holder.getView(R.id.re_spand).setVisibility(View.VISIBLE);
                    iv_arrow.setImageResource(R.mipmap.arrow_u);
                }
            }
        });

    }
}
